/**
 * Created by Administrator on 2017/7/16.
 */
Ext.onReady(function () {
    // 定义表单  
    var formPanel = new Ext.FormPanel({
        style: 'margin-left:200px;margin-right:200px;margin-top:10px;margin-bottom:670px',
        frame: true
        , fileUpload: true
        , url: 'upload.do'
        , method : 'POST'
        , title: '上传文件'
        , items:[{
            xtype:'textfield',
            allowBlank:false,
            fieldLabel:'选择文件',
            inputType:'file',
            name:'fileName'
        }]
        , buttonAlign:'center'
        , buttons:[{
            text:'上传',
            handler: function() {
                if(formPanel.form.isValid()) {
                    formPanel.form.submit({
                        url:'upload.do',
                        method:'POST',
                        waitMsg:'文件上传中...',
                        success: function() {
                            Ext.Msg.alert("系统提示", "文件上传成功！");
                        },
                        failure: function() {
                            Ext.Msg.alert("系统提示", "文件上传失败！");
                        }
                    });
                } else {
                    Ext.Msg.alert("系统提示","请选择文件后再上传！");
                }
            }
        }]
    });

    //数据源
    var jsonStore = new Ext.data.JsonStore({
        fields : ['filesName', 'size', 'time', 'operation']
    });

    //定义列
    var column = new Ext.grid.ColumnModel({
        columns:[
            {header:'文件名', dataIndex:'filesName'},
            {header:'大小', dataIndex:'filesName'},
            {header:'上传时间', dataIndex:'filesName'},
            {header:'操作', dataIndex:'filesName'}
        ]
    });

    // 定义窗口  
    var win = new Ext.Window( {
        title : '文件列表',
        layout : 'fit',
        width : 1000,
        height : 800,
        anchor:'100%',
        closeAction : 'close',
        closable : false,
        plain : true,
        items : formPanel

    });
    win.show();
});